﻿<?php
require_once(dirname(__FILE__)."/../../libs/login/login.php"); 
require_once(dirname(__FILE__)."/../../libs/dbclass/dbconnect.php");
require_once(dirname(__FILE__)."/../../libs/string/libstr.php");
require_once(dirname(__FILE__)."/../../libs/string/pager.php");
require_once(dirname(__FILE__)."/../../config/comm.php");
$lg=new login();
$lg->checklogin("admin_member");//检验是否登录
$mc=new libstr();
$pg=new pager();


//删除留言
$delid=$mc->Ismp($_GET["del"]);
if($delid!=""){
	$sql2="update meseage set isshow='2' where id=$delid ";  //更新状态
	$db->cmd ($sql2);
}

//还原
$reid=$mc->Ismp($_GET["re"]);
if($reid!=""){
	$sql2="update meseage set isshow='1' where id=$reid ";  //更新状态
	$db->cmd ($sql2);
}



$isshow=$mc->Ismp($_GET['isshow']);
$isshow!=''?$where=" where `isshow`='".$isshow."'":$where="where `isshow`='1'";


$type=$mc->Ismp($_GET['type']);
$type!=''?$where.=" and `type`='".$type."'":'';

$sql="select * from  meseage ".$where."  order by addtime desc";
$msgArr=$db->ds($sql);


$path="网站留言";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="../css/css.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" media="screen" href="../../plug/colorbox/colorbox.css">
<script type="text/javascript" src="../js/jquery.js"></script>
<SCRIPT LANGUAGE="JAVASCRIPT" SRC="../../plug/colorbox/jquery.colorbox-min.js"></SCRIPT>
<script type="text/javascript">
//搜素列表
function mbsearch(){
	$("#mbsearch").submit();	
}
//全选操作
function checkall(){
	
   if($("#checkedAll").attr("checked") == true){ //check all
  $("input[name='items[]']").each(function(){
     $(this).attr("checked",true);
    });

   }else{
 $("input[name='items[]']").each(function(){
     $(this).attr("checked",false);
	     });
   }
}

//执行操作多个
function zhixing(){
	if($("input[type=checkbox][name='items[]']:checked").length==0){
		alert("您还没选中任何资源！");
		return;
	}
if(confirm("您确定要执行所选项？")){
	$("#czform").submit();
	return;
	}
}

function openWin(u,n,w, h) {
     var l = (screen.width - w) / 2;
     var t = (screen.height - h) / 2;
     var s = 'width=' + w + ', height=' + h + ', top=' + t + ', left=' + l;
     s += ', toolbar=no, scrollbars=yes, menubar=no, location=no, resizable=no';
     open(u, n, s);
}

//弹出iframe层
function iframePopu(url, widthVal, heightVal){
	$(".iframebox").colorbox({iframe:true, href:url, width:widthVal, height:heightVal, opacity:0.50});
}

</script>


</head>
<body style="background:#fff"> 

<div class="content">
    <div class="right">
   <table width="100%" border="0" cellspacing="0" cellpadding="0">
   	<tr>
        <td width="100%" height="24" class="top_head">&nbsp;</td>
      </tr>
      <tr>
        <td valign="top">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="1%" align="right"  height="45">&nbsp;</td>
                <td width="99%" >
                 <table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="55%" style="padding-left:20px;padding-top:10px;"><img src="../images/head.gif" width="13" height="11"><b><?php echo $path;?></b></td>
                    <td width="45%" align="right">&nbsp;</td>
                  </tr>
                </table>
                </td>
              </tr>
            </table>
        </td>
      </tr>
      <tr>
        <td>
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="bg">
          <tr >
            <td valign="middle"  style=" padding:5px 0 5px 0;" >
            	<table width="92%"  border="0" cellspacing="0" align="center">
                	<tr>
                    	<td width="20%" align="left">
                        	<Div class="xuanxiang">
                                <input type="submit" name="button" id="button" value="全部" onclick="location.href='meseage_list.php?type=<?php echo $type ?>'" <?php if($isshow!="2"){?>class="active"<?php }?>/>
                                <input type="submit" name="button" id="button" value="回收站" onclick="location.href='meseage_list.php?isshow=2&type=<?php echo $type ?>'"<?php if($isshow=="2"){?>class="active" <?php }?> />
                             </Div>
                        </td>
                    	<td width="80%">
                        	<div class="xuanze">

                                   <select name="keyname" onChange="location.href='meseage_list.php?isshow=<?php echo $isshow ?>&type=' + this.options[this.selectedIndex].value">
                                   <option value="" <?php if($type==""){ ?>selected<?php }?>  >全部</option>
                                   <option value="1" <?php if($type=="1"){ ?>selected<?php }?> > <?php echo $message_type[1]?></option>
                                   <option value="2" <?php if($type=="2"){ ?>selected<?php }?> ><?php echo $message_type[2]?></option>
                                  </select>
                          
                              
                          </div>
                        </td>
                    </tr>
                </table>
             </td>
          </tr>
      
      <tr>
      	<td valign="middle" align="center" >
             <table width="92%"   border="1px" bordercolor="#ccc" cellspacing="0px" style="border-collapse:collapse">
                  <thead align="center" bgcolor="#EEEEEE">
                    <tr>
                    	<th  width="3%" height="28" align="left"  >&nbsp;</th>
                        <th  width="10%" height="28" align="center" >名称</th>
                        <th width="13%" height="28" align="center">邮箱</th>
                        <th width="15%" height="28" align="center">电话</th>
                        <th width="20%" height="28" align="center">内容</th>
                        <th width="15%" height="28" align="center">类型</th>
                        <th width="25%" colspan="2" align="center">操作</th>
                    </tr>
                  </thead>
              <tbody>
               <form action="" method="POST" id="czform">
                <?php if(count($msgArr)>0){ ?>   
              <?php foreach ($msgArr as $rs){?>
              	<tr align="center" bgcolor="#FFFFFF">
                	<td  height="28" align="center"><input name="items[]" type="checkbox" value="<?php echo $rs["id"];?>" /></td>
                	<td  align="center" ><?php echo $rs["name"]?> </td>
                	 <td height="28" align="center"><?php echo $rs["email"];?></td>
                    <td height="28" align="center"><?php echo $rs["phone"];?></td>
                    <td height="28" align="left" style="padding-left:10px;"><a href="javascript;" onClick="iframePopu('message_detail.php?id=<?php echo $rs["id"];?>',550,350)" class="iframebox" ><?php echo $rs["status"]=='1'?'<b style="color:red; font-size:8px;">(未读) </b>':''; echo $rs["content"];?></a></td>
                    <td height="28" align="center"><?php echo $message_type[$rs["type"]];?></td>
                    <td height="28" colspan="2" align="center">
                    <bdo><input type="button" name="button8" id="button8" value="查看" onclick="openWin('message_detail.php?id=<?php echo $rs["id"];?>','<?php echo $rs["name"]?>的留言',550,350)"/></bdo>
                    <?php if($isshow=='1'){?>
                    <bdo><input type="button" name="button8" id="deleteone" value="删除" onclick="if(confirm('您确定删除本项吗?')){location.href='?del=<?php echo $rs["id"];?>'}"/></bdo>
                   	<?php } if($isshow=='2'){?>
                    <bdo><input type="button" name="button8" id="deleteone" value="还原" onclick="if(confirm('您确定还原本项吗?')){location.href='?re=<?php echo $rs["id"];?>'}"/></bdo>
                    <?php }?>
                    </td>
                </tr>
            <?php } }else{?>
             <tr align="center" bgcolor="#FFFFFF">
               
                    <td height="30" colspan="9" align="center">对不起，暂时找不到相关资源！</td>
                    
                </tr>
                <?php }?>
              <?php if($pagetext!=""){?>
                  <tr align="center" bgcolor="#FFFFFF">
                  <td height="40" align="center">&nbsp;</td>
              	  <td height="40" align="left">&nbsp;</td>
              	  <td height="40">&nbsp;</td>
              	  <td height="40">&nbsp;</td>
              	  <td height="50" colspan="4" align="right" valign="middle"><ul>
                  <?php echo $pagetext;?>
                    </ul></td>
                    </tr>
                    <?php }?>
                  <!-- <tr align="center" bgcolor="#FFFFFF"> 
                      <td height="28" align="center" ><input type="checkbox" value="checkbox" id="checkedAll" name="checkedAll" onclick="checkall()"></td>
                      <td height="28" align="left" colspan="7">全选
                         <select name="cz" id="select">
                            <option  value="-2">删除</option>
                            <option  value="-3">彻底删除</option>
                         </select> 
                        <input type="button" name="czbtn" id="czbtn" value="执行" onclick="zhixing()" class="czbtn"/></td>
                  </tr>-->
                  </form>
              </tbody>
            </table>
            </td>
          </tr>
        </table>
        </td>
      </tr>
    </table>
    </div>
</div>
</body>
</html>